<template>
  <div>
    <div class="title-wrap">
      <div class="title">广告分组</div>
      <div style="margin-right: 10px">
        <span class="filter-label">时间：</span>
        <el-date-picker
          size="small"
          v-model="timerValue"
          type="daterange"
          :picker-options="pickerOptions"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd"
          format="yyyy-MM-dd"
          align="right"
          :clearable="false"
          @change="searchTime"
        />
        <el-button type="primary" class="searchbutton" size="mini">查询</el-button>
      </div>
    </div>
    <el-main style="background:#fff;"> 
       <el-table :data="tableData.slice((currentPage-1)*pagesize,currentPage*pagesize)" border stripe
                :header-cell-style="{'text-align':'center','background':'rgb(84, 92, 100)','color':'#666','color':'#fff'}" style="width: 100%"
                :default-sort="{prop: tableData.index, order: 'null'}">
            <el-table-column prop="project" label="项目" align="center">
                </el-table-column>
                <el-table-column prop="account" label="账户" align="center">
                </el-table-column>
                <el-table-column prop="manager" label="负责人" align="center">
                </el-table-column>
            </el-table>
            <el-row type="flex" justify="end" style="margin-top: 20px">
                <el-pagination
                  background
                  layout="prev, pager, next"
                  :page-size="pagesize"
                  :current-page="currentPage"
                  :total="pagetotal"
                  @current-change="handleCurrentChange">
                </el-pagination>
            </el-row>
   </el-main>
  </div>
</template>
<script>
export default {
  data() {
    return {
         pagesize:10,
      pagetotal:10,
      currentPage:1,
         tableData: [{
        project: '2016-05-02',
        manager: '王小虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王2虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王3虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王4虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },{
        project: '2016-05-02',
        manager: '王4虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王5虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王6虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王7虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王8虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王8虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王9虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王10虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王11虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王12虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王13虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王14虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王15虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王16虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王17虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王18虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王19虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },{
        project: '2016-05-02',
        manager: '王20虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王小虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王小虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王小虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王小虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王小虎',
        account: '上海市普陀区金沙江路 1518 弄'
      },
      {
        project: '2016-05-02',
        manager: '王小虎',
        account: '上海市普陀区金沙江路 1518 弄'
      }],
      timerValue: "",
      orderList: [],
      pickerOptions: {
        shortcuts: [
          {
            text: "昨天",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24);
              end.setTime(end.getTime() - 3600 * 1000 * 24);
              start.setHours(0);
              start.setMinutes(0);
              start.setSeconds(0);
              end.setHours(23);
              end.setMinutes(0);
              end.setSeconds(0);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "今天",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime());
              start.setHours(0);
              start.setMinutes(0);
              start.setSeconds(0);
              end.setHours(23);
              end.setMinutes(0);
              end.setSeconds(0);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              start.setHours(0);
              start.setMinutes(0);
              start.setSeconds(0);
              end.setHours(23);
              end.setMinutes(0);
              end.setSeconds(0);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              start.setHours(0);
              start.setMinutes(0);
              start.setSeconds(0);
              end.setHours(23);
              end.setMinutes(0);
              end.setSeconds(0);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              start.setHours(0);
              start.setMinutes(0);
              start.setSeconds(0);
              end.setHours(23);
              end.setMinutes(0);
              end.setSeconds(0);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
    };
  },
  mounted() {
    this.pagetotal = this.tableData.length
  },
  methods: {
      userInfo(){

      },
      //时间选择器
      searchTime(val){
          console.log(val,666);
      },
    handleCurrentChange(val){
         console.log(`当前页: ${val}`);
         //拿到新的数据再渲染
         this.currentPage = val
       }
  },
};
</script>
<style scoped>
  .el-header {
    background-color: #B3C0D1;
    color: #333;
    line-height: 60px;
    padding: 0;
  }
  
  .el-aside {
    color: #333;
  }
.title {
  padding: 0 20px;
  height: 60px;
  line-height: 60px;
}
.title-wrap {
  display: flex;
  height: 60px;
  line-height: 60px;
}
.searchbutton{
    margin-left: 20px;
}
</style>
